Dashboard.addWidget({
getId : function(){
return 'table-overview-widget';
},
getName : function(){
return 'Table Overview';
},
getDescription : function(){
return {
en : 'Widget that display a tabular overview of the current model and goals status',
de : 'Widget that display a tabular overview of the current model and goals status'
};
},
getIconClass : function(){
return 'glyphicon glyphicon-th-large';
},
createContent : function(configuration, currentWidgetInstanceId){
var displayedGoalIdList = [];
var displayedKpiIdList = [];
var numModels = 0;
var numKpi = 0;
var numGoals = 0;
var numErrors = 0;
var numGoalSuccess = 0;
var numGoalFailure = 0;
var numGoalUnknown = 0;
var infoList = {};
ModelManager.getKpiModelList().forEach(function(modelItem){
numModels++;
infoList[modelItem.id] = {
modelName : modelItem.name,
objList : {}
};
ModelManager.getTopLevelElementList(modelItem.id).forEach(function(item){
var _countRec = function(modelId, isGoal, objInfo){
if(isGoal){
if(displayedGoalIdList.indexOf(objInfo.id) != -1)
return;
displayedGoalIdList.push(objInfo.id);
} else {
if(displayedKpiIdList.indexOf(objInfo.id) != -1)
return;
displayedKpiIdList.push(objInfo.id);
}
if(isGoal)
numGoals++;
else
numKpi++;
var measure = null;
var errorDescription = null;
try{
measure = isGoal ? Dashboard.evaluateGoal(currentWidgetInstanceId, modelId, objInfo.id) : Dashboard.evaluateKpi(currentWidgetInstanceId, modelId, objInfo.id);
}catch(e){
errorDescription = e;
numErrors++;
}
infoList[modelItem.id].objList[objInfo.id] = {
objectName : objInfo.name,
isGoal : isGoal,
measure : measure,
errorDescription : errorDescription
};
if(measure != null){
if(isGoal && measure.status>0)
numGoalSuccess++;
if(isGoal && measure.status<0)
numGoalFailure++;
if(isGoal && measure.status==0)
numGoalUnknown++;
}
if(isGoal)
objInfo.requiredGoalList.forEach(function(item){
_countRec(modelId, true, item);
});
objInfo.requiredKpiList.forEach(function(item){
_countRec(modelId, false, item);
});
};
var objInfo = item.isAGoal?ModelManager.getGoalInfo(modelItem.id, item.id):ModelManager.getKpiInfo(modelItem.id, item.id);
_countRec(modelItem.id, item.isAGoal, objInfo);
});
});
var _createCircleCode = function(color){
return'';
}
var ret = $('
').append(
$('').append(
$('\
Total models | \
Total KPIs | \
Total Goals | \
Errors | \
Succeeded Goals | \
Failed Goals | \
Unevaluable Goals | \
\
')
).append(
$('').append(
$(''+numModels+' | ').popover({
placement : 'auto right',
container : 'body',
html : true,
title : 'Total Models Details',
content : function(){
var html = '';
html += 'Models |
';
for(var modelInfoKey in infoList)
html += ''+infoList[modelInfoKey].modelName+' |
';
html += '';
return html;
}(),
trigger : 'hover'
})
).append(
$(''+numKpi+' | ').popover({
placement : 'auto right',
container : 'body',
html : true,
title : 'Total KPIs Details',
content : function(){
var html = '';
for(var modelInfoKey in infoList){
html += ''+infoList[modelInfoKey].modelName+' |
';
for(var objInfoKey in infoList[modelInfoKey].objList){
if(infoList[modelInfoKey].objList[objInfoKey].isGoal === false)
html += ''+infoList[modelInfoKey].objList[objInfoKey].objectName+' |
';
}
}
html += '';
return html;
}(),
trigger : 'hover'
})
).append(
$(''+numGoals+' | ').popover({
placement : 'auto right',
container : 'body',
html : true,
title : 'Total Goals Details',
content : function(){
var html = '';
for(var modelInfoKey in infoList){
html += ''+infoList[modelInfoKey].modelName+' |
';
for(var objInfoKey in infoList[modelInfoKey].objList){
if(infoList[modelInfoKey].objList[objInfoKey].isGoal === true)
html += ''+infoList[modelInfoKey].objList[objInfoKey].objectName+' |
';
}
}
html += '';
return html;
}(),
trigger : 'hover'
})
).append(
$(''+numErrors+' | ').popover({
placement : 'auto right',
container : 'body',
html : true,
title : 'Errors Details',
content : function(){
var html = '';
for(var modelInfoKey in infoList){
var trHead = 'Errors in '+infoList[modelInfoKey].modelName+' Goals: | |
';
var trBody = '';
for(var objInfoKey in infoList[modelInfoKey].objList){
var obj = infoList[modelInfoKey].objList[objInfoKey];
if(obj.isGoal === true && obj.measure === null && obj.errorDescription != null)
trBody += ''+obj.objectName+' | '+obj.errorDescription+' |
';
}
if(trBody != '')
html += trHead + trBody;
trHead = 'Errors in '+infoList[modelInfoKey].modelName+' KPIs: | |
';
trBody = '';
for(var objInfoKey in infoList[modelInfoKey].objList){
var obj = infoList[modelInfoKey].objList[objInfoKey];
if(obj.isGoal === false && obj.measure === null && obj.errorDescription != null)
trBody += ''+obj.objectName+' | '+obj.errorDescription+' |
';
}
if(trBody != '')
html += trHead + trBody;
}
html += '';
return html;
}(),
trigger : 'hover'
})
).append(
$(''+numGoalSuccess+' '+_createCircleCode('green')+' | ').popover({
placement : 'auto right',
container : 'body',
html : true,
title : 'Succeeded Goals Details',
content : function(){
var html = '';
for(var modelInfoKey in infoList){
html += ''+infoList[modelInfoKey].modelName+' |
';
for(var objInfoKey in infoList[modelInfoKey].objList){
var obj = infoList[modelInfoKey].objList[objInfoKey];
if(obj.isGoal === true && obj.measure !== null && obj.measure.status>0)
html += ''+obj.objectName+' |
';
}
}
html += '';
return html;
}(),
trigger : 'hover'
})
).append(
$(''+numGoalFailure+' '+_createCircleCode('red')+' | ').popover({
placement : 'auto right',
container : 'body',
html : true,
title : 'Failed Goals Details',
content : function(){
var html = '';
for(var modelInfoKey in infoList){
html += ''+infoList[modelInfoKey].modelName+' |
';
for(var objInfoKey in infoList[modelInfoKey].objList){
var obj = infoList[modelInfoKey].objList[objInfoKey];
if(obj.isGoal === true && obj.measure !== null && obj.measure.status<0)
html += ''+obj.objectName+' |
';
}
}
html += '';
return html;
}(),
trigger : 'hover'
})
).append(
$(''+numGoalUnknown+' '+_createCircleCode('grey')+' | ').popover({
placement : 'auto right',
container : 'body',
html : true,
title : 'Unevaluable Goals Details',
content : function(){
var html = '';
for(var modelInfoKey in infoList){
html += ''+infoList[modelInfoKey].modelName+' |
';
for(var objInfoKey in infoList[modelInfoKey].objList){
var obj = infoList[modelInfoKey].objList[objInfoKey];
if(obj.isGoal === true && obj.measure !== null && obj.measure.status==0)
html += ''+obj.objectName+' |
';
}
}
html += '';
return html;
}(),
trigger : 'hover'
})
)
)
);
return ret;
},
getConfiguration : function(){
return {};
},
createConfiguration : function(presetConfig){
return {
nodeElement : null,
okHandler : function(){return {};}
};
},
getPreferredSize : function(){
return {w:10, h:3};
}
});